package com.lc.hongtai.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.lc.hongtai.R;
import com.lc.hongtai.adapter.FragmentAdapter2;
import com.lc.hongtai.fragment.InvestListFragment;
import com.lc.hongtai.fragment.ProductDetailFragment;
import com.zcx.helper.bound.BoundView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/4/24.
 */
public class ProductDetailActivity extends BaseFragmentActivity implements View.OnClickListener, OnTabSelectListener {

    @BoundView(R.id.tl_2)
    private SlidingTabLayout tl_2;
    private ViewPager vp_FindFragment_pager;
    private FragmentPagerAdapter fAdapter;
    private List<Fragment> list_fragment;
    private List<String> list_title;
    private ProductDetailFragment fragment1;
    private InvestListFragment fragment2;
    private final String[] mTitles = {
            "经济", "生活",
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_product);

        tl_2 = (SlidingTabLayout) findViewById(R.id.tl_2);

        initControls();

    }


    private void initControls() {

        vp_FindFragment_pager = (ViewPager) findViewById(R.id.vp);


        fragment1 = new ProductDetailFragment();
        fragment2 = new InvestListFragment();


        list_fragment = new ArrayList<>();

        list_fragment.add(ProductDetailFragment.getInstance(getIntent().getStringExtra("url")));
        list_fragment.add(InvestListFragment.getInstance(getIntent().getStringExtra("url1")));


        list_title = new ArrayList<>();
        list_title.add("产品详情");
        list_title.add("投资记录");

        fAdapter = new FragmentAdapter2(getSupportFragmentManager(), list_fragment, list_title);

        vp_FindFragment_pager.setAdapter(fAdapter);

        tl_2.setViewPager(vp_FindFragment_pager);
        tl_2.setOnTabSelectListener(this);

    }

    @Override
    public void onTabSelect(int position) {

    }

    @Override
    public void onTabReselect(int position) {

    }
}
